const amqp=require('amqp-connection-manager')
const connect=require('../../util/rabbitmq');
class consumeQueue{
    constructor(queue_name){
        this.queue_name=queue_name;
        const self=this;
        this.channelWrapper = connect.createChannel({
            confirm:false
        });
    }
    async createChannel(consumeMes){
        const self=this;
        await this.channelWrapper.addSetup(function(channel){
            console.log('创建channel 并监听');
            return Promise.all([
                channel.assertQueue(self.queue_name, {durable: false})
                ]);
        });
        await this.channelWrapper.consume(self.queue_name,consumeMes)
        this.channelWrapper.waitForConnect();
    }
    // consumeMes(data){
    //     var message = JSON.parse(data.content.toString());
    //     console.log("receiver: get message", message);
    // }
}
module.exports=consumeQueue;